package com.itheima.mapper;

import com.itheima.pojo.Permission;
import com.itheima.pojo.Role;
import com.itheima.pojo.User;
import com.itheima.pojo.UserLogin;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
@Mapper
public interface UserMapper {
    /*
    *   查询全部员工数
    * */
    @Select("select * from users,roles where users.role_id = roles.id")
    List<User> list();

    /*
    *   根据id删除用户数据
    * */
    @Delete("delete from users where id = #{id}")
    void deleteById(Integer id);
    /*
    *   新增用户
    * */
    @Insert("insert into users(username,password,phoneNumber,role_id,image,create_time,update_time) " +
            "values(#{username},#{password},#{phoneNumber},#{roleId},#{image},#{createTime},#{updateTime})")
    void insert(User user);


    @Select("select * from users where phoneNumber = #{phoneNumber} and password = #{password}")
    User login(User user);
    @Select("select * from users where id = #{id}")
    User getUserById(int id);

    void update(User user);
    @Select("select * from roles")
    List<Role> getRoles();
    List<Permission> getPermissions(int id);
}
